﻿using System;
using Sautom.ClientComunication;
using Sautom.ClientComunication.Commands;
using Sautom.ClientComunication.FileService;
using Sautom.ClientComunication.Helpers;

namespace Sautom.Modules.Client.Commands
{
    public class PrintOrderDetailsCommand : CommandBase<Guid>
    {
        #region Properties
        private ClientFileHelper ClientFileHelper { get; set; }
        private IFileService FileServiceClient { get; set; }
        #endregion

        #region Constructors
        public PrintOrderDetailsCommand(ClientFileHelper clientFileHelper, IFileService fileServiceClient)
        {
            ClientFileHelper = clientFileHelper;
            FileServiceClient = fileServiceClient;
        }
        #endregion

        #region Overrides of CommandBase

        public override void Execute(Guid orderId)
        {
            //todo find good name for the template rendener
            var fileData = FileServiceClient.ClientContract(orderId, "OrderDetails");

            if (fileData != null && fileData.FileData.Length != 0)
            {
                ClientFileHelper.PrintDocxFile(fileData.FileData);
            }
        }

        #endregion
    }
}
